package com.hnue.k60b.newapplication;

import java.util.List;

import com.hnue.k60b.adapter.NewAdapter;
import com.hnue.k60b.models.RssItem;
import com.hnue.k60b.utils.Variables;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

public class NewListActivity extends ListActivity {

	private List<RssItem> item;

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {

		super.onListItemClick(l, v, position, id);
		Intent intend = new Intent(this, NewActivity.class);
		intend.putExtra(Variables.LINK, item.get(position).getLink());
		startActivity(intend);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle bundle = getIntent().getExtras();
		int category = bundle.getInt(Variables.CATAGORY);
		int paper = bundle.getInt(Variables.PAPER);
		setTitle(Variables.CATAGORIES[paper][category]);
		int key = paper * 1000 + category;
		item = Variables.newmap.get(key);
		NewAdapter adapter = new NewAdapter(this, Variables.ICONS[paper],item);
		setListAdapter(adapter);

	}

}
